#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
package ${package}.setup.module.code.mapper;

import ${package}.common.bean.po.Code;
import ${package}.common.bean.po.CodeType;
import ${package}.common.bean.vo.QueryBean;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Set;

/**
 * Description: 代码类型及代码Mapper
 *
 * @author wenxiaopeng
 * @date 2020/07/21 17:33
 *
 * <pre>
 *              ${copyright}
 *      Copyright (c) 2019. All Rights Reserved.
 * </pre>
 */
@Repository
public interface CodeMapper {

	/**
	 * Description:
	 * <新增codetype>
	 *
	 * @param code 1
	 * @author wenxiaopeng
	 * @date 14:55 2020/07/26
	 **/
	void addCodeType(CodeType code);

	/**
	 * Description:
	 * <新增code>
	 *
	 * @param code 1
	 * @author wenxiaopeng
	 * @date 15:19 2020/07/26
	 **/
	void addCode(Code code);

	/**
	 * Description:
	 * <删除代码类型>
	 *
	 * @param id   1
	 * @author wenxiaopeng
	 * @date 17:22 2020/07/26
	 **/
	void deleteCodeType(Long id);

	/**
	 * Description:
	 * <删除代码>
	 *
	 * @param id   1
	 * @author wenxiaopeng
	 * @date 17:22 2020/07/26
	 **/
	void deleteCode(Long id);

	/**
	 * Description:
	 * <查询code type po>
	 *
	 * @param id   1
	 * @return ${package}.corplution.bean.po.CodeType
	 * @author wenxiaopeng
	 * @date 23:04 2020/07/26
	 **/
	CodeType findCodeTypeById(Long id);

	/**
	 * Description:
	 * <查询type下的code>
	 *
	 * @param id   1
	 * @return java.util.List<${package}.corplution.bean.po.Code>
	 * @author wenxiaopeng
	 * @date 23:09 2020/07/26
	 **/
	List<Code> findCodeByType(Long id);

	/**
	 * Description:
	 * <查询指定codetype下的指定code>
	 * @param id 1
	 * @param code 2
	 * @author wenxiaopeng
	 * @date 16:04 2021/06/17
	 * @return ${package}.common.bean.po.Code
	 **/
	Code findCodeByTypeAndCode(Long id, String code);

	/**
	 * Description:
	 * <更新代码值>
	 *
	 * @param code 1
	 * @author wenxiaopeng
	 * @date
	 **/
	void updateCode(Code code);

	/**
	 * Description:
	 * <更新代码类型>
	 *
	 * @param codeType 1
	 * @author wenxiaopeng
	 * @date
	 **/
	void updateCodeType(CodeType codeType);

	/**
	 * Description:
	 * <查询指定代码>
	 *
	 * @param id   1 代码id
	 * @return ${package}.corplution.bean.po.Code
	 * @author wenxiaopeng
	 * @date
	 **/
	Code findCode(Long id);

	/**
	 * Description:
	 * <移动代码排序>
	 *
	 * @param codeTypeId 2
	 * @param direction  front/back
	 * @param order      4
	 * @author wenxiaopeng
	 * @date
	 **/
	void moveCodes(Long codeTypeId, String direction, Integer order);

	/**
	 * Description:
	 * <按codetype删除>
	 *
	 * @param codeTypeId 1
	 * @author wenxiaopeng
	 * @date
	 **/
	void deleteCodesByCodeType(Long codeTypeId);

	/**
	 * Description:
	 * <查询下级代码>
	 *
	 * @param upperCodes 1
	 * @return java.util.List<${package}.corplution.bean.po.Code>
	 * @author wenxiaopeng
	 * @date
	 **/
	List<Code> findSubCodes(@Param("upperCodes") Set<Long> upperCodes);

	/**
	 * Description:
	 * <批量插入代码>
	 *
	 * @param codes 1
	 * @author wenxiaopeng
	 * @date
	 **/
	void batchAddCode(@Param(value = "codes") List<Code> codes);

	/**
	 * Description:
	 * <向前移动代码>
	 * @author zhoutt
	 * @date 13:56 2020/10/27
	 * @param codeTypeId 1
	 * @param start 3
	 * @param end 4
	 **/
    void moveCodesForward(Long codeTypeId, Integer start, Integer end);

	/**
	 * Description:
	 * <向后移动代码>
	 * @author zhoutt
	 * @date 13:56 2020/10/27
	 * @param codeTypeId 1
	 * @param start 3
	 * @param end 4
	 **/
	void moveCodesBackward(Long codeTypeId, Integer start, Integer end);

	/**
	 * Description:
	 * <分页获取codeType列表>
	 * @param queryBean 1
	 * @author wenxiaopeng
	 * @date 14:31 2021/06/17
	 * @return java.util.List<${package}.common.bean.po.CodeType>
	 **/
	List<CodeType> findCodeTypeLimits(QueryBean queryBean);

	/**
	 * Description:
	 * <按代码值查询code type>
	 * @param codeType 1
	 * @author wenxiaopeng
	 * @date 08:58 2021/06/24
	 * @return ${package}.common.bean.po.CodeType
	 **/
	CodeType findCodeTypeByCode(String codeType);

	/**
	 * Description:
	 * <查询指定codeType以及upperCode的子Code>
	 * @param codeTypeId 1
	 * @param upperCodeId 2
	 * @author wenxiaopeng
	 * @date 16:11 2021/06/17
	 * @return java.util.List<${package}.common.bean.po.Code>
	 **/
	List<Code> findCodeByTypeAndUpperCode(Long codeTypeId, Long upperCodeId);

	/**
	 * Description:
	 * <获取最新Code>
	 * @param codeTypeId 1
	 * @author wenxiaopeng
	 * @date 16:36 2021/06/17
	 * @return java.lang.String
	 **/
	String findLatestCode(Long codeTypeId);

	/**
	 * Description:
	 * <根据code查询详情>
	 * @param code 1
	 * @author wenxiaopeng
	 * @date 09:39 2021/06/22
	 * @return ${package}.common.bean.vo.CodeVo
	 **/
	Code findCodeVoByCode(@Param("code") String code);

	/**
	 * Description:
	 * <>
	 * @author wenxiaopeng
	 * @date 10:08 2021/06/22
	 * @return java.util.List<${package}.common.bean.po.CodeType>
	 **/
	List<CodeType> findCodeTypeList();

}
